package com.chc.finance.sys.bo;

import java.net.UnknownHostException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;


import com.chc.finance.sys.dao.SecDao;
import com.chc.finance.sys.vo.User;
import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.DBCursor;
import com.mongodb.Mongo;
import com.synnex.dataentry.encrypt.EncryptUtil;

public class SecBo {
	@Resource
	private SecDao secDao;
	public void test(){
//		User user= new User();
//		user.setId(1);
//		user.setName("admin");
//		user.setUid("admin");
//		user.setEmail("chc_129@163.com");
//		user.setPwd(EncryptUtil.encrypt("123"));
//		
//		secDao.save(user);
//		
//		User use2r= new User();
//		use2r.setId(2);
//		use2r.setName("test1");
//		use2r.setUid("test1");
//		use2r.setEmail("ch@163.com");
//		use2r.setPwd(EncryptUtil.encrypt("123"));
//		secDao.save(use2r);
		
		User user=(User)secDao.findById("4", User.class);
		System.out.println(user.getUid());
//		
//		User user2=(User)secDao.findById(1, User.class);
//		System.out.println(user2.getName());
		Map <String,Object > whereMap= new HashMap<String,Object>();
		whereMap.put("name", "test5");
		Map <String,Object > valueMap= new HashMap<String,Object>();
		valueMap.put("uid", "aaaa");
		System.out.println(secDao.update(whereMap, valueMap, User.class));
		
		User users=(User)secDao.findById("4", User.class);
		System.out.println(users.getUid());
	}
	public static void main(String[] args) {
		Mongo mongo;
		try {
			mongo = new Mongo();
			DB db = mongo.getDB("finance");
			DBCollection users = db.getCollection("User");
			DBCursor cur = users.find();
			while (cur.hasNext()) {
			System.out.println(cur.next());

			}
		} catch (UnknownHostException e) {
			e.printStackTrace();
		}
		
	}
}
